<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String path = request.getContextPath();
	// 获得本项目的地址(例如: http://localhost:8080/MyApp/)赋值给basePath变量 
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	// 将 "项目路径basePath" 放入pageContext中，待以后用EL表达式读出。 
	pageContext.setAttribute("basePath", basePath);
	//out.write(basePath);
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link href="<%=basePath%>bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
<link href="<%=basePath%>bootstrap/css/style.css" rel="stylesheet">

<!-- Bootstrap core CSS -->
<link
	href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css"
	rel="stylesheet">

<!-- Optional Bootstrap Theme -->
<link href="data:text/css;charset=utf-8,"
	data-href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css"
	rel="stylesheet" id="bs-theme-stylesheet">

<link href="../assets/css/patch.css" rel="stylesheet">

<!-- Documentation extras -->
<link href="<%=basePath%>bootstrap/assets/css/docs.min.css"
	rel="stylesheet">
<!--[if lt IE 9]><script src="../../bootstrap/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script
	src="<%=basePath%>bootstrap/assets/js/ie-emulation-modes-warning.js"></script>

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<!-- Bootstrap core CSS -->
<!-- Optional Bootstrap Theme -->
<link href="data:text/css;charset=utf-8,"
	data-href="../../bootstrap/css/bootstrap-theme.min.css"
	rel="stylesheet" id="bs-theme-stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style type="text/css">
/**文本框内容右对齐**/
label {
	text-align: right;
}
/**自定义row的行距**/
.rowHeigth {
	margin-top: 10px;
}
</style>
<script src="<%=basePath%>bootstrap/js/jquery.min.js"></script>
<script src="<%=basePath%>bootstrap/js/bootstrap.min.js"></script>
<script src="<%=basePath%>bootstrap/js/scripts.js"></script>
<script type="text/javascript">
	function getScores() {
		//获取成绩批量插入的参数格式  “主键id:成绩,主键id:成绩”
		var strParas = "";
		var i = 0;
		//成绩单主键
		var stuid = $("#stuid" + i).get(0);
		//成绩
		var score = $("#score" + i).get(0);
		while (stuid != undefined && stuid != null && score != undefined
				&& score != null) {
			//拼写参数字符串
			strParas += stuid.value + ":" + score.value + ",";
			// 下标加1
			++i;
			//继续遍历
			stuid = $("#stuid" + i).get(0);
			score = $("#score" + i).get(0);
		}

		$("#txtscores")[0].value = strParas;

		console.info("txtscores:" + strParas);
	}
</script>
</head>
<body>
	<div>

		<form action="<%=basePath%>StuCourseManagerServlet?opt=1"
			method="post">

			<div class="container-fluid">
				<div class="row rowHeigth">

					<input type="hidden" id="txtUserId" name="opt" value="2">

					<div class="form-group">
						<label class="col-sm-2 control-label">授课教师</label>
						<div class="col-sm-4">
							<label class="col-sm-2 control-label">${teaB.teaname }</label> <input
								type="hidden" class="form-control" id="txtTeacher"
								name="txtTeacher" value="${teaB.teaid }">
						</div>

						<label class="col-sm-2 control-label">课程</label>
						<div class="col-sm-4">
							<select class="form-control" id="txtCourse" name="txtCourse">
								<c:forEach items="${lstCou }" var="eachC" varStatus="st">
									<option value="${eachC.couid }">${eachC.couname }</option>
								</c:forEach>
							</select>
						</div>
					</div>

				</div>

				<div class="row rowHeigth">
					<div class="form-group">
						<div class="col-sm-offset-4 col-sm-2">
							<button type="submit" class="btn btn-default">查询</button>
						</div>
						<div class="col-sm-offset-2 col-sm-4">
							<button type="reset" class="btn btn-default">重置</button>
						</div>
					</div>

				</div>

			</div>
		</form>
		<form action="<%=basePath%>StuCourseManagerServlet?opt=2"
			method="post">
			<input type="hidden" class="form-control" id="txtscores"
				name="txtscores">

			<div class="bs-example">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>#</th>
							<th>姓名</th>
							<th>学号</th>
							<th>课程</th>
							<th>成绩</th>
							<th>输入成绩</th>
						</tr>
					</thead>
					<tbody>

						<c:forEach items="${lstSco }" var="eachInfo" varStatus="st">
							<tr>
								<input type="hidden" class="form-control"
									id="stuscoreid" name="stuscoreid"
									value="${eachInfo.scoid }">
								<td>${st.index+1 }</td>
								<td>${eachInfo.stuname }</td>
								<td>${eachInfo.stuid }</td>
								<td>${eachInfo.couname }</td>
								<td>${eachInfo.score }</td>

								<td><input type="text" class="form-control" id="txtscores"
									name="txtscores"></td>

							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>

			<div class="row rowHeigth">
				<div class="form-group">
					<div class="col-sm-offset-4 col-sm-2">
						<button type="submit" class="btn btn-default">提交</button>
							<!-- <button type="submit" class="btn btn-default"
							onclick="getScores();">提交</button> -->
					</div>
					<div class="col-sm-offset-2 col-sm-4">
						<button type="reset" class="btn btn-default">重置</button>
					</div>
				</div>

			</div>
		</form>
	</div>
</body>
</html>